package book.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import book.pojo.Book;
import book.service.BookService;

@Controller("indexController")

public class IndexController {
	
	@Autowired
	private BookService bookService;
	@RequestMapping(value="/",method = RequestMethod.GET)
	public String getHot(Model model) {
//		System.out.println("gethot");
		List<Book> books = bookService.getHot();
		model.addAttribute("books", books);
		return "forward:index2.jsp";
	}
	@RequestMapping("/index/login")
	public String login() {
		return "login";
	}
	
	@RequestMapping("/index/logout")
	public String logout(HttpSession session) {
		session.invalidate();
		return "redirect://";
	}
	
	@RequestMapping("/index/regist")
	public String regist() {
		return "register";
	}

}
